using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using way.model;
using way.util;

namespace way.dao
{
    public interface IMenuMapper
    {
        Result<Dictionary<int, MenuEntity>> queryMenu(Result<Dictionary<int, MenuEntity>> res, AppDbContext conn);
        Result<int> menuAddHead(MenuEntity menu, Result<int> res, AppDbContext conn);
    }
    public class MenuMapper: IMenuMapper
    {
        public Result<Dictionary<int, MenuEntity>> queryMenu(Result<Dictionary<int, MenuEntity>> res, AppDbContext conn) {
            try {
                res.data = conn.menus.ToDictionary(m=>m.id);
            }
            catch (Exception ex)
            {
                res.setStatus(ResultCode.exceptionStatus, ex.Message);
            }
            return res;
        }
        public Result<int> menuAddHead(MenuEntity menu, Result<int> res, AppDbContext conn)
        {
            try
            {
                
            }
            catch (Exception ex)
            {
                res.setStatus(ResultCode.exceptionStatus, ex.Message);
            }
            return res;
        }
    }
}
